package com.ecoolex.ying.space.core;

import com.ecoolex.framework.cg.mybatis.MyBatisCodeGenerator;
import com.ecoolex.framework.cg.mybatis.core.ClassPluginInterface;
import com.ecoolex.framework.cg.mybatis.pojo.KeyValue;
import com.ecoolex.framework.cg.mybatis.support.DaoClassGenerate;
import com.ecoolex.framework.cg.mybatis.support.ManagerClassGenerate;


public class YingSpaceMyBatisCodegen {

    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        // 配置项目路径
        MyBatisCodeGenerator generator = MyBatisCodeGenerator.create("src/main/java",
            "com.ecoolex.ying.space.core",
            KeyValue.create(ClassPluginInterface.TARGET_ENTITY, "com.ecoolex.ying.space.entity"),
            KeyValue.create(ClassPluginInterface.OVERRIDE, "false"));
        // 添加转移目录
        generator.addTransferPackage("com.ecoolex.ying.space.entity", "../ying-space-entity/");
        // 配置数据库
        generator.setJdbcConnection("com.mysql.jdbc.Driver",
            "jdbc:mysql://47.101.161.12:3306/template-ying-space?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull",
            "root",
            "Kcxx1245!",
            KeyValue.create("nullCatalogMeansCurrent", "true"));
        // 配置插件
        // 扩展dao插件
        generator.addPlugin(DaoClassGenerate.class);
        // 业务逻辑插件
        generator.addPlugin(ManagerClassGenerate.class);

        // 配置表
        // 自动增长主键模版
        // generator.createDefaultTable("member", "Member", "id");
        // 非自增长主键，自设主键模版
        // generator.createDefaultTable("user_info", "UserInfo");

        /**
         * 商城部分
         */
        // 商品分类
        generator.createDefaultTable("goods_category", "GoodsCategory", "CategoryId");
        // 外购商品
        generator.createDefaultTable("outsourcing_goods", "OutsourcingGoods", "OutsourcingGoodsId");
        generator.createDefaultTable("outsourcing_packaged", "OutsourcingPackaged", "OutsourcingPackagedId");
        generator.createDefaultTable("outsourcing_packaged_goods", "OutsourcingPackagedGoods", "Id");
        // 首页营销目录
        generator.createDefaultTable("markting_catalog", "MarktingCatalog", "CatalogId");
        generator.createDefaultTable("markting_catalog_goods", "MarktingCatalogGoods", "Id");
        // 意见反馈
        generator.createDefaultTable("feedback", "Feedback", "Id");
        // 整屋案例
        generator.createDefaultTable("whole_house_case", "WholeHouseCase", "CaseId");
        generator.createDefaultTable("whole_house_case_items", "WholeHouseCaseItems", "ItemId");
        // 整屋案例营销
        generator.createDefaultTable("markting_whole_house_case", "MarktingWholeHouseCase", "Id");
        /**
         * 映空间部分
         */
        // 用户扩展信息
        generator.createDefaultTable("user_info_ext", "UserInfoExt");
        generator.createDefaultTable("user_identity_authentication","UserIdentityAuthentication");
        // 用户关注
        generator.createDefaultTable("user_watch", "UserWatch", "Id");
        // 用户收藏
        generator.createDefaultTable("user_favorite", "UserFavorite", "FavoriteId");
        generator.createDefaultTable("user_favorite_items", "UserFavoriteItems", "FavoriteItemId");
        // 点赞
        generator.createDefaultTable("user_like_record", "UserLikeRecord", "Id");
        generator.createDefaultTable("user_like_and_favorite_read_state", "UserLikeAndFavoriteReadState");
        // 用户作品、灵感
        generator.createDefaultTable("user_works", "UserWorks", "WorksId");
        generator.createDefaultTable("user_works_statistical", "UserWorksStatistical");
        // 图文
        generator.createDefaultTable("user_works_images", "UserWorksImages");
        // 视频
        generator.createDefaultTable("user_works_video", "UserWorksVideo");
        // 作品
        generator.createDefaultTable("user_works_opus", "UserWorksOpus");
        generator.createDefaultTable("user_works_opus_items", "UserWorksOpusItems", "ItemId");
        // 标签
        generator.createDefaultTable("user_works_shopping", "UserWorksShopping", "Id");
        //作品营销位
        generator.createDefaultTable("user_works_markting", "UserWorksMarkting", "MarktingId");
        generator.createDefaultTable("user_works_markting_detail", "UserWorksMarktingDetail", "Id");
        
        // 作品、灵感评论
        generator.createDefaultTable("user_works_comment", "UserWorksComment", "CommentId");
        generator.createDefaultTable("user_works_comment_read_state", "UserWorksCommentReadState");
        //消息
        generator.createDefaultTable("push_message", "PushMessage", "Id");
        generator.createDefaultTable("push_message_read_state", "PushMessageReadState");

        /**
         * v2.0 商品库
         */
        // 商品属性
        generator.createDefaultTable("goods_brand", "GoodsBrand", "BrandId");
        generator.createDefaultTable("goods_classify", "GoodsClassify", "ClassifyId");
        generator.createDefaultTable("goods_label", "GoodsLabel", "LabelId");
        // 附件
        generator.createDefaultTable("goods_attachment", "GoodsAttachment", "AttachmentId");
        // 商品
        generator.createDefaultTable("goods", "Goods", "GoodsId");
        generator.createDefaultTable("goods_label_associate", "GoodsLabelAssociate", "Id");
        generator.createDefaultTable("goods_barcode", "GoodsBarcode", "Id");
        generator.createDefaultTable("goods_product", "GoodsProduct", "ProductId");
        generator.createDefaultTable("goods_product_barcode", "GoodsProductBarcode", "Id");
        generator.createDefaultTable("goods_spec_group", "GoodsSpecGroup", "SpecGroupId");
        generator.createDefaultTable("goods_spec", "GoodsSpec", "SpecId");
        // 优选商品
        generator.createDefaultTable("pick_goods", "PickGoods", "PickGoodsId");
        generator.createDefaultTable("pick_goods_channel", "PickGoodsChannel", "ChannelId");
        generator.createDefaultTable("pick_goods_product", "PickGoodsProduct", "PickProductId");
        generator.createDefaultTable("pick_goods_label_associate", "PickGoodsLabelAssociate", "Id");
        // 优选商品搜索
        generator.createView("search_pick_goods", "SearchPickGoods");
        /**
         * 设计师项目
         */
        generator.createDefaultTable("designer_project", "DesignerProject", "ProjectId");
        generator.createDefaultTable("designer_project_attribute", "DesignerProjectAttribute");
        generator.createDefaultTable("designer_project_share", "DesignerProjectShare");
        generator.createDefaultTable("designer_project_items", "DesignerProjectItems", "ItemsId");
        generator.createDefaultTable("designer_project_items_product", "DesignerProjectItemsProduct", "ItemsProductId");
        generator.createDefaultTable("designer_project_items_product_custom", "DesignerProjectItemsProductCustom");
        // 用户优选商品收藏
        generator.createDefaultTable("user_pick_goods_favorite", "UserPickGoodsFavorite", "Id");
        // 用户商品附件下载任务
        generator.createDefaultTable("user_goods_attachment_download_task", "UserGoodsAttachmentDownloadTask", "Id");

        /**
         * 地产项目代金券活动
         */
        generator.createDefaultTable("estate_project_activity", "EstateProjectActivity", "ProjectId");
        generator.createDefaultTable("estate_project_activity_coupon", "EstateProjectActivityCoupon", "CouponId");
        generator.createDefaultTable("estate_project_activity_coupon_order", "EstateProjectActivityCouponOrder", "OrderId");
        generator.createDefaultTable("estate_project_activity_coupon_package", "EstateProjectActivityCouponPackage", "Id");
        generator.createDefaultTable("estate_project_activity_goods", "EstateProjectActivityGoods", "ActivityGoodsId");
        generator.createDefaultTable("estate_project_activity_goods_order", "EstateProjectActivityGoodsOrder", "OrderId");
        generator.createDefaultTable("estate_project_activity_goods_order_detail", "EstateProjectActivityGoodsOrderDetail", "DetailId");
        generator.createDefaultTable("estate_project_activity_goods_order_customer", "EstateProjectActivityGoodsOrderCustomer", "Id");
        generator.createDefaultTable("estate_project_activity_goods_order_refund_audit", "EstateProjectActivityGoodsOrderRefundAudit", "AuditId");
        generator.createDefaultTable("estate_project_activity_house_model", "EstateProjectActivityHouseModel", "ModelId");
        generator.createDefaultTable("estate_project_activity_house_model_items", "EstateProjectActivityHouseModelItems", "ItemId");
        generator.createDefaultTable("estate_project_activity_house_model_items_goods", "EstateProjectActivityHouseModelItemsGoods", "Id");
        generator.createDefaultTable("estate_project_activity_goods_category", "EstateProjectActivityGoodsCategory", "ActivityCategoryId");
        generator.createDefaultTable("estate_project_activity_brand", "EstateProjectActivityBrand", "BrandId");
        generator.createDefaultTable("estate_project_activity_external_goods", "EstateProjectActivityExternalGoods", "ExternalGoodsId");
        generator.createDefaultTable("estate_project_activity_external_goods_category", "EstateProjectActivityExternalGoodsCategory", "ExternalGoodsCategoryId");
        //支付订单
        generator.createDefaultTable("payment_order", "PaymentOrder", "PaymentOrderId");
        generator.createDefaultTable("payment_order_record", "PaymentOrderRecord", "Id");
        generator.generate();
    }
}
